import request from '../utils/request';

export function devmacList(params) {
  let url;
  if(params.sortField){
     url = `api/devmac/list?page=${params.page}&per_page=${params.results}&q={"order_by": [{"field": "${params.sortField}", "direction": "${params.sortOrder}"}]}`;
  }else{
     url = `api/devmac/list?page=${params.page}&per_page=${params.results}`
  }
  return request(url);
}

export async function batchImport(params) {
  return request(`api/devmac/batch_import`, {
    method: "POST",
    body: {
      ...params,
    },
  });
}

export async function activate(params) {
  return request(`api/devmac/activate?dev_imei=${params.dev_imei}&dev_mac=${params.dev_mac}`);
}

export async function deactivate(params) {
  return request(`api/devmac/deactivate?dev_imei=${params.dev_imei}&dev_mac=${params.dev_mac}`, {
    method: "POST",
    body: {
      ...params,
    },
  });
}

export async function disabled(params) {
  return request(`api/devmac/disabled?dev_imei=${params.dev_imei}&dev_mac=${params.dev_mac}`, {
    method: "POST",
    body: {
      ...params,
    },
  });
}